package net.jxiny.oschina.tweet.TweetActivity;


import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;


import com.okhttplib.HttpInfo;
import com.okhttplib.OkHttpUtil;
import com.okhttplib.callback.Callback;

import net.jxiny.oschina.R;
import net.jxiny.oschina.net.URLList;
import net.jxiny.oschina.util.ACache;


import java.io.IOException;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class SendAnswerActivity extends AppCompatActivity {
    @BindView(R.id.add_answer_back)
    ImageView imageView;
    @BindView(R.id.add_answer_question)
    EditText editText;
    @BindView(R.id.add_answer_submit)
    ImageView textView;


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add_answer);
        ButterKnife.bind(this);
    }
    @OnClick({ R.id.add_answer_back,R.id.add_answer_submit})
    public void onViewCliked(View view){
        switch (view.getId()){
            case  R.id.add_answer_back: finish();break;
            case R.id.add_answer_submit:
                OkHttpUtil.getDefault(this)
                        .doGetAsync(HttpInfo.Builder().setUrl(URLList.SEND_ADD_ANSWER +"?title="+editText
                                .getText().toString()+"&access_token="+
                                ACache.get(this).getAsString("token")).build(), new Callback() {
                            @Override
                            public void onSuccess(HttpInfo info) throws IOException {

                                Toast.makeText(SendAnswerActivity.this,"发送成功",Toast.LENGTH_SHORT).show();

                            }

                            @Override
                            public void onFailure(HttpInfo info) throws IOException {
                                Toast.makeText(SendAnswerActivity.this,"发送失败",Toast.LENGTH_SHORT).show();

                            }
                        });
        }
    }
}
